home *** CD-ROM | disk | FTP | other *** search
- on initScanTag
- global gGlossNum, gGlossNumLines
- set glossNum to the number of member "glossary"
- set lc to the number of lines in field glossNum
- set gGlossNum to glossNum
- set gGlossNumLines to lc
- end
-
- on resetScanTag
- global gScanCount
- set gScanCount to -1
- end
-
- on scanTag
- global gScanCount, wc, gStartT, gSecondGlossWord
- set fMem to 17
- set TagColour to 137
- if voidp(gScanCount) or (gScanCount < 0) then
- set gScanCount to 1
- set wc to the number of words in field fMem
- resetHit()
- set gStartT to the timer
- end if
- if gScanCount < wc then
- set aword to word gScanCount of field fMem
- set matchCount to matchWord(aword)
- if matchCount = 1 then
- set the foreColor of word gScanCount of field fMem to TagColour
- else
- if (matchCount = 2) and (gScanCount < wc) then
- if gSecondGlossWord = word gScanCount + 1 of field fMem then
- set the foreColor of word gScanCount to gScanCount + 1 of field fMem to TagColour
- end if
- end if
- end if
- set gScanCount to gScanCount + 1
- if gScanCount = wc then
- set EndT to the timer
- set duration to EndT - gStartT
- put "elapsed = " & duration & " Rate = " & wc * 60.0 / duration & " wps"
- end if
- end if
- end
-
- on matchWord oWord
- global gGlossNum, gGlossNumLines, gHitList, gSecondGlossWord
- if the number of chars in oWord < 3 then
- return 0
- end if
- set aword to wordFilter(oWord)
- if voidp(gGlossNum) or voidp(gGlossNumLines) then
- makegloss()
- end if
- set glossNum to gGlossNum
- set stPt to 1
- set EndPt to gGlossNumLines
- set bExit to 0
- set bFound to 0
- set gSecondGlossWord to EMPTY
- repeat while not bExit
- set midPt to (stPt + EndPt) / 2
- set midLine to line midPt of field glossNum
- set midLineWord1 to word 1 of midLine
- set midLineWord1s to midLineWord1 & "s"
- if (midLineWord1 = aword) or (midLineWord1s = aword) then
- if not getAt(gHitList, midPt) then
- set bFound to the number of words in midLine
- setAt(gHitList, midPt, 1)
- if bFound > 1 then
- set gSecondGlossWord to word 2 of midLine
- end if
- end if
- set bExit to 1
- next repeat
- end if
- if stPt >= EndPt then
- set bExit to 1
- end if
- if midLine > aword then
- set EndPt to midPt - 1
- next repeat
- end if
- set stPt to midPt + 1
- end repeat
- return bFound
- end
-
- on resetHit
- global gHitList
- set gHitList to []
- repeat with a = 1 to the number of lines in field "glossary"
- add(gHitList, 0)
- end repeat
- end
-
- on wordFilter oWord
- set cc to the number of chars in oWord
- set c1 to charToNum(char 1 of oWord)
- set CL to charToNum(char cc of oWord)
- set bC1isAlpha to isAlpha(c1)
- set bCLisAlpha to isAlpha(CL)
- if bC1isAlpha and bCLisAlpha then
- set fWord to oWord
- else
- set fWord to oWord
- repeat while not bC1isAlpha and (cc > 2)
- delete char 1 of fWord
- set cc to cc - 1
- set c1 to charToNum(char 1 of fWord)
- set bC1isAlpha to isAlpha(c1)
- end repeat
- set cc to the number of chars in fWord
- repeat while not bCLisAlpha and (cc > 2)
- delete char cc of fWord
- set cc to cc - 1
- set CL to charToNum(char cc of fWord)
- set bCLisAlpha to isAlpha(CL)
- end repeat
- end if
- return fWord
- end
-
- on isAlpha C
- return ((C >= 65) and (C <= 90)) or ((C >= 97) and (C <= 122))
- end
-